/*intarray.hpp
#ifndef INTARRAY_H
#define INTARRAY_H

class IntArray  {
                int *data;
                int n;
        public:
                IntArray(int n = 1);
                ~IntArray();
                IntArray &operator = (const IntArray &other);
                IntArray &operator ++ ();
                void print();
};
#endif
*/

#include <cstdlib>
#include <cstring>
#include <iostream>

#include "IntArray.hpp"

using namespace std;

IntArray::IntArray(int n) {
    this->n = n;
    data = new int[n];
    for (int i = 0; i < n; i++) data[i] = i;
}

IntArray::~IntArray() {
    delete[] data;
}

IntArray& IntArray::operator=(const IntArray& other) {
    if (this != &other) {
        this->n = other.n;
        delete[] this->data;
        this->data = new int[n];
        memcpy(this->data, other.data, n * sizeof(int));
    }
    return *this;
}

IntArray& IntArray::operator++() {
    IntArray temp(n);
    for (int i = 0; i < n; i++) {
        temp.data[i] = data[i];
    }
    delete[] data;
    data = new int[n + 1];
    for (int i = 0; i < n; i++) {
        data[i] = temp.data[i];
    }
    data[n] = n;
    n++;
    delete[] temp.data;
    return *this;
}

void IntArray::print() {
    for (int i = 0; i < n; i++) {
        cout << data[i] << " ";
    }
    cout << endl;
}
